package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ActivePrizeConfig;
import com.ruoyi.system.enums.ActivePrizeEnum;
import com.ruoyi.system.mapper.ActivePrizeConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ActiveBoxConfigMapper;
import com.ruoyi.system.domain.ActiveBoxConfig;
import com.ruoyi.system.service.IActiveBoxConfigService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-18
 */
@Service
public class ActiveBoxConfigServiceImpl implements IActiveBoxConfigService {

    @Autowired
    private ActiveBoxConfigMapper activeBoxConfigMapper;

    @Autowired
    private ActivePrizeConfigMapper activePrizeConfigMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public ActiveBoxConfig selectActiveBoxConfigById(Long id) {
        return activeBoxConfigMapper.selectActiveBoxConfigById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param activeBoxConfig 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<ActiveBoxConfig> selectActiveBoxConfigList(ActiveBoxConfig activeBoxConfig) {
        return activeBoxConfigMapper.selectActiveBoxConfigList(activeBoxConfig);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param activeBoxConfig 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertActiveBoxConfig(ActiveBoxConfig activeBoxConfig) {
        activeBoxConfig.setCreateTime(DateUtils.getNowDate());
        int i = activeBoxConfigMapper.insertActiveBoxConfig(activeBoxConfig);

        List<ActivePrizeConfig> prizeList = ActivePrizeEnum.initPrize(activeBoxConfig.getId());
        prizeList.forEach(activePrizeConfigMapper::insertActivePrizeConfig);
        return i;
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param activeBoxConfig 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateActiveBoxConfig(ActiveBoxConfig activeBoxConfig) {
        return activeBoxConfigMapper.updateActiveBoxConfig(activeBoxConfig);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteActiveBoxConfigByIds(Long[] ids) {
        return activeBoxConfigMapper.deleteActiveBoxConfigByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteActiveBoxConfigById(Long id) {
        return activeBoxConfigMapper.deleteActiveBoxConfigById(id);
    }
}
